<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>商品管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		.imgsty{
			width:50px;
			height:50px;
		}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/goods/bizGoods">商品列表</a></li>
		<shiro:hasPermission name="goods:bizGoods:edit"><li><a href="${ctx}/goods/bizGoods/form">商品添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="bizGoods" action="${ctx}/goods/bizGoods" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>商品描述：</label>
				<form:input path="goodTitle" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<li><label>售卖方式：</label>
				<form:select path="sellType" class="input-medium">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('sell_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>商品类别ID：</label>
				<form:select path="goodCategoryId" class="input-medium">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('good_category_id')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>主键</th>
				<th>商品标题</th>
				<th>商品头图</th>
				<th>售价积分</th>
				<th>售卖方式</th>
				<th>商品状态</th>
				<th>商品类型</th>
				<th>开始时间</th>
				<th>结束时间</th>
				<th>商品类别名称</th>
				<th>库存数</th>
				<th>创建时间</th>
				<shiro:hasPermission name="goods:bizGoods:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="bizGoods">
			<tr>
				<td><a href="${ctx}/goods/bizGoods/form?opt=detail&id=${bizGoods.id}">
					${bizGoods.id}
				</a></td>
				<td>
					${bizGoods.goodTitle}
				</td>
				<td>
					<img id="goodShowPic" alt="商品头图" class="imgsty" src="${not empty bizGoods.goodPic?bizGoods.goodPic:'/static/img/timg.jpg'}" />
				</td>
				<td>
					${bizGoods.priceJifen}
				</td>
				<td>
					${fns:getDictLabel(bizGoods.sellType, 'sell_type', '')}
				</td>
				<td>
					${fns:getDictLabel(bizGoods.goodStatus, 'goodsStatus', '')}
				</td>
				<td>
					${fns:getDictLabel(bizGoods.goodType, 'goodType', '')}
				</td>
				<td>
					<fmt:formatDate value="${bizGoods.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<fmt:formatDate value="${bizGoods.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${bizGoods.goodCategoryName}
				</td>
				<td>
					${bizGoods.stockNum}
				</td>
				<td>
					<fmt:formatDate value="${bizGoods.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<shiro:hasPermission name="goods:bizGoods:edit"><td>
					<a href="${ctx}/goods/bizGoods/form?id=${bizGoods.id}">修改</a>
					<c:if test="${bizGoods.goodStatus==2}">
						<a href="${ctx}/goods/bizGoods/save?id=${bizGoods.id}&goodStatus=1" onclick="return confirmx('确认要上架该商品吗？', this.href)">上架</a>
    					<a href="${ctx}/goods/bizGoods/save?id=${bizGoods.id}&goodStatus=3" onclick="return confirmx('确认要删除该商品吗？', this.href)">删除</a>
					</c:if>
					
					<c:if test="${bizGoods.goodStatus==1}">
						<a href="${ctx}/goods/bizGoods/save?id=${bizGoods.id}&goodStatus=2" onclick="return confirmx('确认要下架该商品吗？', this.href)">下架</a>
						<a href="${ctx}/goods/bizGoods/save?id=${bizGoods.id}&goodStatus=3" onclick="return confirmx('确认要删除该商品吗？', this.href)">删除</a>
					</c:if>
					<c:if test="${bizGoods.goodStatus==3}">
						<a href="${ctx}/goods/bizGoods/save?id=${bizGoods.id}&goodStatus=3" onclick="return confirmx('确认要删除该商品吗？', this.href)">删除</a>
					</c:if>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>